package o2o.dao.TO.sync;

import com.jinyou.utils.common.Geohash;
import lombok.Data;
import lombok.experimental.Accessors;
import o2o.company.model.ShopInfo;
import org.springframework.beans.BeanUtils;

/**
 * @author Jahnke【1029777564@qq.com】
 * @ClassName ShopTO
 * @Description: 商户信息
 * @date 2019/8/6 14:39
 * @Version 1.0
 */
@Data
@Accessors(chain = true)
public class ShopTO {

    private Long id;
    private String shopName;
    private String ownName;
    private String phone;
    private Double lng;
    private Double lat;

    private String province;
    private String city;
    private String county;
    private String address;

    public ShopInfo converToShop() {
        ShopInfo info = new ShopInfo();
        BeanUtils.copyProperties(this, info);
        info.setTelephone(this.getPhone()).setShopRole(1).setIsGroupShop(0).setOrderCounts(0);
        if (Geohash.isChinaLocal(info.getLat(), info.getLng())) {
            info.setGeocode(Geohash.encode(info.getLat(), info.getLng()));
        }

        return info;
    }
}
